import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///景区门票分类
class TickSortWidget extends StatefulWidget {
  @override
  _tickSortWidgetState createState() => _tickSortWidgetState();

}

class _tickSortWidgetState extends State<TickSortWidget> {

  int currendIndex=0;
  List<String> vale;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    stList();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.only(left: 10.0,right: 10.0),
      color: Colors.white,
      height: ScreenUtil().setHeight(50.0),
      child: ListView.builder(itemBuilder: (context, index) {
        return itemList(index);
      }, itemCount: vale.length,shrinkWrap: true,scrollDirection: Axis.horizontal,physics: NeverScrollableScrollPhysics(),),
    );
  }

  Widget itemList(int index) {
    return InkWell(
      onTap: (){
       setState(() {
         currendIndex=index;
       });
      },
      child: Container(
        margin: EdgeInsets.only(left: 10.0),
        alignment: Alignment.center,
        padding: EdgeInsets.only(left: 6.0,top: 3.0,right: 6.0,bottom: 3.0),
        decoration: BoxDecoration(
            color: currendIndex==index?Colors.yellow:Colors.yellowAccent[100],
            borderRadius: BorderRadius.all(Radius.circular(8.0))
        ),
        child: Text('${vale[index]}', style: TextStyle(fontSize: ScreenUtil().setSp(18.0),fontWeight: FontWeight.bold),),
      ),
    );
  }

  List<String> stList(){
    vale=new List();
    vale.add('成人票');
    vale.add('学生票');
    return vale;
  }

}